<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>开始了</title>
 
    <link rel="stylesheet" type="text/css" href="./css/bootstrap.css" />
    <style>
        body{
            padding: 100px 200px;
        }
        .form-control{
            min-height:500px;
            margin: 30px;
            border-color: skyblue;
        }
        #editor1 {
            height: 500px;
            display: inline-block;
        }
  
        .music{
            display: none;
        }
        img{
            width: 250px;
            height: 250px;
        }
        #btn2{
            display: none;
        }
        #btn3{
            display: none;
        }
        .button.red{
            margin-left: 90%;
            width: 100px;
            height: 50px;
            box-shadow: 0 1px 2px #8fcaee inset,0 -1px 0 #497897 inset,0 -2px 3px #8fcaee inset;
            background: -webkit-linear-gradient(top,#42a4e0,#2e88c0);
            background: -moz-linear-gradient(top,#42a4e0,#2e88c0);
            background: linear-gradient(top,#42a4e0,#2e88c0);
    }
    </style>
        <link rel="icon" href="./logo.ico">
        <link href="css/buttonStyle.css">
</head>
<body>
<div id="editparent">
    <div><img src="./images/img1.png"></img></div>
    <!-- 编辑器控制按钮 -->
    <div id='editControls' style='text-align:center; padding:5px;'>
        <h1>回望2022年</h1>
    </div>

<!--    div负责文本内容的显示-->
    <div id="editor1" class='form-control'  contenteditable >
        <h3></h3>
    </div>

    <!-- 打字音效 -->
    <audio controls src="/radio/radio5.mp3" id="music3" class="music">
        Your browser does not support the
        <code>audio</code> element.        
</audio>
</div>
<button id="btn1" type="button" class="button red"><b>开始</b></button>


<script>
    
    // 默认文本聚焦的
    var editor1 = document.getElementById("editor1");
    editor1.focus();
    var i = 0;
    var text = ""
    
    var text1 = "#include&lt;stdio.h&gt; int main() { printf(\"Hello World 2023\"); return 0;}";

    var t = ""
    var timer = null;

    var btn1 =  document.getElementById("btn1");

    // 输出字的函数
    function type()
    {
        editor1.focus();
        t += text[i];
        // console.log(t)
        i ++;
        editor1.innerHTML = "<h1>" + t + "</h1>";
        if (i >= text.length){
            
            clearInterval(timer)
            i = 0;
            text="";
            
        }
        
    }
    btn1.onclick = function(){
        console.log("开始");
        editor1.innerHTML = "";
        text = text1;
        timer = setInterval(type, 170);
        let audioPlay = document.getElementById("music3").play();
        btn1.style.display = "none";  
    }
</script>
</body>
</html>
